package com.ghck.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ghck.server.dao.CreditsFrequencyDictMapper;
import com.ghck.server.model.CreditsFrequencyDict;
import com.ghck.server.model.query.CreditsFrequencyDictQuery;
import com.ghck.server.service.CreditsFrequencyDictService;

/**
 * 积分频率  <br>
 * dict_credits_frequency <br>
 * v1.0 2016-05-01
 */
 @Service
 @Transactional
 public class CreditsFrequencyDictServiceImpl implements CreditsFrequencyDictService {
	
	private static final Logger logger = LoggerFactory.getLogger(CreditsFrequencyDictServiceImpl.class);
	
	@Autowired
	private CreditsFrequencyDictMapper creditsFrequencyDictMapper;
	
	/**
 	*根据ID删除 积分频率
 	*/
 	@Override
 	public Integer deleteCreditsFrequencyDictById(Integer id){
 		return creditsFrequencyDictMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 积分频率
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertCreditsFrequencyDict(List<? extends CreditsFrequencyDict> creditsFrequencyDicts){
		Integer count = creditsFrequencyDictMapper.batchInsert(creditsFrequencyDicts);
		return count;
 	}
 	/**
 	*新增 积分频率
 	*/
 	@Override
 	@Transactional
 	public Integer insertCreditsFrequencyDict(CreditsFrequencyDict domain){
		Integer id = creditsFrequencyDictMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 积分频率
 	*/
 	@Override
 	@Transactional
 	public Integer updateCreditsFrequencyDict(CreditsFrequencyDict domain){
		Integer count = creditsFrequencyDictMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 积分频率
 	*/
 	public CreditsFrequencyDict findCreditsFrequencyDictById(Integer id){
 		CreditsFrequencyDict result = creditsFrequencyDictMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 积分频率
 	*/
	public List<CreditsFrequencyDict> findCreditsFrequencyDictByQuery(CreditsFrequencyDictQuery query){
		query.dealWith();
		List<CreditsFrequencyDict> result = creditsFrequencyDictMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (CreditsFrequencyDict creditsFrequencyDict : result) {
				creditsFrequencyDict.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countCreditsFrequencyDictByQuery(CreditsFrequencyDictQuery query){
 		query.dealWith();
 		Integer result = creditsFrequencyDictMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<CreditsFrequencyDict> findCreditsFrequencyDictByIds(List<Integer> ids){
 		List<CreditsFrequencyDict> result = creditsFrequencyDictMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (CreditsFrequencyDict creditsFrequencyDict : result) {
				creditsFrequencyDict.dealWith();
			}
		}
		return result;
 	}
 	
 	/**
 	*根据name查询 身体部位
 	*/
	public CreditsFrequencyDict findByName(String name){
		CreditsFrequencyDict result = creditsFrequencyDictMapper.findByName(name);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
	}
	
	/**
 	*获取所有字典 身体部位
 	*/
	public List<CreditsFrequencyDict> findAll(){
		List<CreditsFrequencyDict> result = creditsFrequencyDictMapper.findAll();
		if(CollectionUtils.isNotEmpty(result)) {
			for (CreditsFrequencyDict creditsFrequencyDict : result) {
				creditsFrequencyDict.dealWith();
			}
		}
		return result;
	}
}	